//
//  LRJVideoListTableViewCell.m
//  BreadTravel
//
//  Created by 李润嘉 on 15/12/29.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LRJVideoListTableViewCell.h"

@implementation LRJVideoListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView
{
    

    
    self.bigImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.bigImageView];
    
    UIImageView *viedoImage = [[UIImageView alloc] initWithFrame:CGRectMake(-3, -3, 50, 50)];
    viedoImage.image = [UIImage imageNamed:@"iconfont-shipin(2).png"];
    [self.bigImageView addSubview: viedoImage];

    self.whiteImage = [[UIImageView alloc] init];
    self.whiteImage.image = [UIImage imageNamed:@"whiteImage.png"];
    self.whiteImage.alpha = 0.5;
    [self.contentView addSubview:self.whiteImage];
    
    self.tagsLabel = [[UILabel alloc] init];
    self.tagsLabel.font = [UIFont systemFontOfSize:12];
    self.tagsLabel.textAlignment = NSTextAlignmentCenter;
    [self.whiteImage addSubview:self.tagsLabel];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.font = [UIFont systemFontOfSize:20];
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.bigImageView addSubview:self.nameLabel];
    
}
- (void)setVideoModel:(LRJVideoModel *)videoModel
{
    [self.bigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.right.mas_equalTo(@0);
        make.height.mas_equalTo(@220);
        
    }];
    
    
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.bigImageView.mas_centerX);
        make.centerY.equalTo(self.bigImageView.mas_centerY);
        
    }];
    
    [self.whiteImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.nameLabel.mas_top).offset(-5);
        make.centerX.equalTo(self.nameLabel.mas_centerX);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(@50);
        
    }];
    
    [self.tagsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(self.whiteImage.mas_centerX);
        make.centerY.equalTo(self.whiteImage.mas_centerY);

        
    }];
    

    
    NSURL *url = [NSURL URLWithString:videoModel.imageHref];
    [self.bigImageView sd_setImageWithURL:url placeholderImage:IMAGE];
    self.nameLabel.text = videoModel.name;
    self.tagsLabel.text = videoModel.tags;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
